#include<iostream>
#include<algorithm>
using namespace std;
const int N = 110;
int arr[N];
int main()
{
	int n;
	int mi = 0;
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		sum += arr[i];
		mi = min(mi, sum);
	}
	cout << sum - mi << endl;
	return 0;
}